// pagesWorkOrderSearchFilter/pagesWorkOrderSearchFilter.js
import {
  SUB_PAGES
} from "../../config/router.config";
import {
  createStoreBindings
} from 'mobx-miniprogram-bindings'
import {
  workOrderSearchIndexFilterStore
} from '../../store/workOrderSearchIndexFilterStore'
import {
  deptSelectStore
} from "../../store/deptSelectStore";
import {
  handleFilterRouter
} from "../../utils/util";

const mixin_dicKey = require('../../common/mixins/dicKey')

Page({
  behaviors: [mixin_dicKey],
  /**
   * 页面的初始数据
   */
  data: {},


  onFilterDept() {
    const toUrl = `${SUB_PAGES.Filter.FILTER_DEPT_SELECT.router}?${handleFilterRouter(SUB_PAGES.WorkOrder.WORK_ORDER_SEARCH_INDEX_FILTER.router, 'selectDept','workOrderSearchDeptValue' )}`
    wx.navigateTo({
      url: toUrl,
    })
  },

  onFilterDepGroupUser() {
    const toUrl = `${SUB_PAGES.Filter.FILTER_DEPT_SELECT.router}?${handleFilterRouter(SUB_PAGES.WorkOrder.WORK_ORDER_SEARCH_INDEX_FILTER.router, 'selectDeptGroupUser','workOrderSearchDeptTeamUserValue' )}`
    wx.navigateTo({
      url: toUrl
    })
  },

  // 查询
  onSubmit() {
    wx.navigateTo({
      url: SUB_PAGES.WorkOrder.WORK_ORDER_SEARCH_INDEX.router,
    })
  },
  // 重置
  onReset() {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.storeBindings = createStoreBindings(this, {
      store: workOrderSearchIndexFilterStore,
      fields: ['attributeList', 'attributeType', 'buildIdList', 'currStateList', 'degreeList', 'deptIdList', 'keywords', 'makeDeptIdList', 'makeTeamIdList', 'makeUserIdList', 'rangeTypeList', 'receiveWayList', 'repairEndTime', 'repairStartTime', 'sourceList', 'userId', ],
      actions: ["onTag", 'changeTime'],
    })
    this.storeBindings1 = createStoreBindings(this, {
      store: deptSelectStore,
      fields: ['workOrderSearchDeptValue', 'workOrderSearchDeptTeamUserValue'],
    })
    this.storeBindings1.updateStoreBindings()

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    this.storeBindings.destroyStoreBindings()
    this.storeBindings1.destroyStoreBindings()

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})